﻿use persons
go
------------------1----------------------------------------------------------------
/*Select all person contacts*/
DECLARE  @NAME NVARCHAR(50), @SURNAME NVARCHAR(50)
SET @NAME='Marina'
SET @SURNAME='Shilo'
SELECT 
[Contact].[ContactType], 
[Contact].[ContactValue]
FROM [dbo].[Contact], [dbo].[Person] 
WHERE [Person].[ID]=[Contact].[fk_personId] AND [Person].[FirstName]=@NAME AND [Person].[LastName]=@SURNAME

SELECT 
[Contact].[ContactType], 
[Contact].[ContactValue]
FROM [dbo].[Contact] INNER JOIN [dbo].[Person] 
ON [Person].[ID]=[Contact].[fk_personId] WHERE [Person].[FirstName]=@NAME AND [Person].[LastName]=@SURNAME

SELECT 
[Contact].[ContactType], 
[Contact].[ContactValue]
FROM [dbo].[Contact] WHERE [Contact].[fk_personId] IN(
SELECT  [Person].[ID] FROM [dbo].[Person] WHERE [Person].[FirstName]=@NAME AND [Person].[LastName]=@SURNAME)
